//\file: atTriangle.h

#ifndef __ATOMTRACE_TRIANGLE_H_
#define __ATOMTRACE_TRIANGLE_H_

#include "Vector3.h"
#include "Ray.h"
#include "HitRecord.h"

namespace AtomTrace
{
    class atTriangle{
    private:
        bool _IntersectAreaMethod(const Ray & ray, HitRecord & hRec);
        bool _IntersectDenoMethod(const Ray & ray, HitRecord & hRec);
    public:
        Vector3 v0;
        Vector3 e1;
        Vector3 e2;
        
        //Vector3 N; // plane normal

        int address; // global memory address
        int matID;

        atTriangle();
        atTriangle(const Vector3 & iv0, const Vector3 & iv1, const Vector3 & iv2);
        atTriangle(int address);
        const atTriangle & LoadFromGM(int address); 

        // Intersection function
        bool Intersect(const Ray & ray, HitRecord & hRec);

        // Helper functions
        const Vector3 & operator[](int index) const;
        Vector3 & operator[](int index);
    }; // class atTriangle
} // namespace AtomTrace

#endif // __ATOMTRACE_TRIANGLE_H_
